home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / unix / advsysrc / advsys.1
Encoding:
Text File  |  1989-08-14  |  59.6 KB  |  2,372 lines

  1. Article 12 of comp.sources.games:
  2. Path: tut!osu-cis!cbosgd!ihnp4!homxb!whuts!mtune!rutgers!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request
  3. From: games-request@tekred.TEK.COM
  4. Newsgroups: comp.sources.games
  5. Subject: v02i055:  advsys - adventure writing system, Part01/03
  6. Message-ID: <1731@tekred.TEK.COM>
  7. Date: 23 Oct 87 23:25:46 GMT
  8. Sender: billr@tekred.TEK.COM
  9. Lines: 2357
  10. Approved: billr@tekred.TEK.COM
  11.  
  12. Submitted by: Marc Russell Pawliger <mp1w+@andrew.cmu.edu>
  13. Comp.sources.games: Volume 2, Issue 55
  14. Archive-name: advsys/Part01
  15.  
  16.     [Compiles and runs the sample progrom on our 4.3bsd Vax;
  17.      beyond that no guarantees.  Also, to forestall the questions
  18.      sure to be asked, the submitter did not have the Mac
  19.      dependent file.  -br]
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 1 (of 3)."
  28. # Contents:  README MANIFEST advcom.c advint.h advscn.c advsys.doc
  29. # Wrapped by billr@tekred on Fri Oct  9 16:25:06 1987
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f README -a "${1}" != "-c" ; then 
  32.   echo shar: Will not over-write existing file \"README\"
  33. else
  34. echo shar: Extracting \"README\" \(1098 characters\)
  35. sed "s/^X//" >README <<'END_OF_README'
  36. X From the begining of the advsys.doc file:
  37. X
  38. X          ADVSYS - An Adventure Writing System
  39. X
  40. X              Version 1.2
  41. X
  42. X             by David Betz
  43. X              114 Davenport Avenue
  44. X              Manchester, NH 03103
  45. X             (603) 625-4691 (home)
  46. X
  47. X             July 14, 1986
  48. X
  49. X           Copyright (c) 1986, by David Betz
  50. X              All Rights Reserved
  51. XPermission is hereby granted for unrestricted non-commercial use
  52. X
  53. XADVSYS is a special purpose programming language that was
  54. Xspecifically designed to be used to write computer text
  55. Xadventure games.  It includes a facility for defining the kinds
  56. Xof objects that are common in adventures.  Some objects
  57. Xrepresent locations on the game map, some objects represent
  58. Xthings that the player can find while exploring the adventure
  59. Xworld, and some objects represent other characters that the
  60. Xadventurer can encounter during his or her journeys.  The
  61. Xadventure language also provides a facility to define actions.
  62. XActions are short sections of code that determine what happens
  63. Xin response to a command from the player.  These two concepts,
  64. X"objects" and "actions" form the basis for the adventure
  65. Xlanguage.
  66. END_OF_README
  67. if test 1098 -ne `wc -c <README`; then
  68.     echo shar: \"README\" unpacked with wrong size!
  69. fi
  70. # end of overwriting check
  71. fi
  72. if test -f MANIFEST -a "${1}" != "-c" ; then 
  73.   echo shar: Will not over-write existing file \"MANIFEST\"
  74. else
  75. echo shar: Extracting \"MANIFEST\" \(894 characters\)
  76. sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
  77. X   File Name        Archive #    Description
  78. X-----------------------------------------------------------
  79. X MANIFEST                  1    This shipping list
  80. X Makefile                  3    
  81. X README                    1    
  82. X README2                   3    
  83. X advavl.c                  3    
  84. X advavl.h                  3    
  85. X advcom.c                  1    
  86. X advcom.h                  3    
  87. X advdbs.c                  2    
  88. X advdbs.h                  3    
  89. X advexe.c                  3    
  90. X advexp.c                  2    
  91. X advfcn.c                  2    
  92. X advfio.c                  3    
  93. X advint.c                  3    
  94. X advint.h                  1    
  95. X advjunk.c                 3    
  96. X advmsg.c                  3    
  97. X advprs.c                  3    
  98. X advscn.c                  1    
  99. X advsys.doc                1    
  100. X advtrm.c                  3    
  101. X newadv.pch                3    
  102. X objects.adi               2    
  103. X osample.adv               2    
  104. X readme.1st                3    
  105. END_OF_MANIFEST
  106. if test 894 -ne `wc -c <MANIFEST`; then
  107.     echo shar: \"MANIFEST\" unpacked with wrong size!
  108. fi
  109. # end of overwriting check
  110. fi
  111. if test -f advcom.c -a "${1}" != "-c" ; then 
  112.   echo shar: Will not over-write existing file \"advcom.c\"
  113. else
  114. echo shar: Extracting \"advcom.c\" \(14821 characters\)
  115. sed "s/^X//" >advcom.c <<'END_OF_advcom.c'
  116. X
  117. X/* advcom.c - a compiler for adventure games */
  118. X/*
  119. X    Copyright (c) 1986, by David Michael Betz
  120. X    All rights reserved
  121. X*/
  122. X
  123. X#include "advcom.h"
  124. X#include "advavl.h"
  125. X#include "advdbs.h"
  126. X
  127. X/* symbol tables */
  128. XSYMBOL *symbols;
  129. XARGUMENT *arguments;
  130. XARGUMENT *temporaries;
  131. X
  132. X/* adventure id information */
  133. Xchar aname[19];
  134. Xint aversion;
  135. X
  136. X/* word table */
  137. Xint wtable[WMAX+1],wcnt;
  138. X
  139. X/* object table */
  140. Xint otable[OMAX+1],ocnt;
  141. X
  142. X/* action table */
  143. Xint atable[AMAX+1],acnt;
  144. X
  145. X/* constant, variable and property symbol counts */
  146. Xint ccnt,vcnt,pcnt;
  147. X
  148. X/* data and code space */
  149. Xchar *data,*code;
  150. Xint dptr,cptr;
  151. X
  152. X/* buffer for building an object */
  153. Xint objbuf[OSIZE];
  154. Xint nprops;
  155. X
  156. X/* global variables */
  157. Xchar ifile[FMAX];    /* input file name */
  158. Xchar ofile[FMAX];    /* output file name */
  159. XFILE *ifp;        /* input file pointer */
  160. Xunsigned int msgoff;    /* message section offset */
  161. XTREE *words;        /* word tree */
  162. Xint curwrd;        /* current word number */
  163. Xint curobj;        /* current object */
  164. Xint curact;        /* current action */
  165. Xint def_flag;        /* default action flag value */
  166. Xint def_mask;        /* default action mask value */
  167. X
  168. X/* header information variables */
  169. Xint h_init;        /* initialization code */
  170. Xint h_update;        /* update code */
  171. Xint h_before;        /* before handler code */
  172. Xint h_after;        /* after handler code */
  173. Xint h_error;        /* error handling code */
  174. X
  175. X/* external routines */
  176. Xextern char *malloc();
  177. Xextern char *calloc();
  178. Xextern TREE *tnew();
  179. X
  180. X/* external variables */
  181. Xextern int errcount;    /* error count */
  182. Xextern int t_value;    /* token value */
  183. Xextern char t_token[];    /* token string */
  184. Xextern char *t_names[];    /* token names */
  185. Xextern long ad_foff;    /* data file offset */
  186. X
  187. X/* forward declarations */
  188. XSYMBOL *sfind();
  189. XSYMBOL *senter();
  190. Xchar *save();
  191. X
  192. X/* main - the main routine */
  193. Xmain(argc,argv)
  194. X  int argc; char *argv[];
  195. X{
  196. X    int tkn,obj,i;
  197. X
  198. X    /* initialize */
  199. X#ifdef MAC
  200. X    macinit(ifile,ofile);
  201. X#else
  202. X    printf("ADVCOM v1.2 - Copyright (c) 1986, by David Betz\n");
  203. X#endif
  204. X    wcnt = ocnt = acnt = ccnt = vcnt = pcnt = msgoff = 0;
  205. X    symbols = NULL; arguments = temporaries = NULL;
  206. X    h_init = h_update = h_before = h_after = h_error = NIL;
  207. X    def_flag = def_mask = 0;
  208. X    aname[0] = 0;
  209. X    sinit();
  210. X
  211. X    /* setup the code and data space */
  212. X    if ((data = calloc(1,DMAX)) == 0)
  213. X    fail("insufficient memory");
  214. X    if ((code = calloc(1,CMAX)) == 0)
  215. X    fail("insufficient memory");
  216. X    dptr = cptr = 1;    /* make sure nothing has a zero offset */
  217. X
  218. X    /* get the file name */
  219. X#ifndef MAC
  220. X    if (argc < 2)
  221. X    fail("usage: advcom <file> [ <ofile> ]");
  222. X    strcpy(ifile,argv[1]); strcat(ifile,".adv");
  223. X    strcpy(ofile,(argc < 3 ? argv[1] : argv[2])); strcat(ofile,".dat");
  224. X#endif
  225. X
  226. X    /* open the input file */
  227. X    if ((ifp = fopen(ifile,"r")) == NULL)
  228. X    fail("can't open input file");
  229. X
  230. X    /* create and initialize the output file */
  231. X    ad_create(ofile);
  232. X    for (i = 0; i++ < 512; ad_putc('\0'))
  233. X    ;
  234. X
  235. X    /* create the word tree */
  236. X    words = tnew();
  237. X
  238. X    /* enter builtin constants */
  239. X    center("t",-1);
  240. X    center("nil",0);
  241. X    /* enter the builtin variables */
  242. X    venter("$actor");
  243. X    venter("$action");
  244. X    venter("$dobject");
  245. X    venter("$ndobjects");
  246. X    venter("$iobject");
  247. X    venter("$ocount");
  248. X
  249. X    /* enter the preposition "to" */
  250. X    add_word("to",WT_PREPOSITION);
  251. X
  252. X    /* process statements until end of file */
  253. X    while ((tkn = token()) == T_OPEN) {
  254. X    frequire(T_IDENTIFIER);
  255. X
  256. X    /* identification statement */
  257. X    if (match("adventure"))
  258. X        do_adventure();
  259. X
  260. X    /* vocabulary statements */
  261. X    else if (match("adjective"))
  262. X        do_word(WT_ADJECTIVE);
  263. X    else if (match("preposition"))
  264. X        do_word(WT_PREPOSITION);
  265. X    else if (match("conjunction"))
  266. X        do_word(WT_CONJUNCTION);
  267. X    else if (match("article"))
  268. X        do_word(WT_ARTICLE);
  269. X    else if (match("synonym"))
  270. X        do_synonym();
  271. X
  272. X    /* constant, variable, function and default definition statements */
  273. X    else if (match("define"))
  274. X        do_define();
  275. X    else if (match("variable"))
  276. X        do_variable();
  277. X    else if (match("default"))
  278. X        do_default();
  279. X
  280. X    /* property definition statement */
  281. X    else if (match("property"))
  282. X        do_defproperty();
  283. X
  284. X    /* handle the init, before and after code statements */
  285. X    else if (match("init"))
  286. X        h_init = do_code(t_token);
  287. X    else if (match("update"))
  288. X        h_update = do_code(t_token);
  289. X    else if (match("before"))
  290. X        h_before = do_code(t_token);
  291. X    else if (match("after"))
  292. X        h_after = do_code(t_token);
  293. X    else if (match("error"))
  294. X        h_error = do_code(t_token);
  295. X
  296. X    /* action definition statement */
  297. X    else if (match("action"))
  298. X        do_action();
  299. X
  300. X    /* object definition statements */
  301. X        else if (match("object"))
  302. X        do_object(t_token,NIL);
  303. X
  304. X    /* object instance definition statements */
  305. X    else if (obj = ofind(t_token))
  306. X        do_object(t_token,obj);
  307. X
  308. X    /* error, unknown statement */
  309. X    else
  310. X        error("Unknown statement type");
  311. X    }
  312. X    require(tkn,T_EOF);
  313. X
  314. X    /* close the input file */
  315. X    fclose(ifp);
  316. X
  317. X    /* output the data structures */
  318. X    output();
  319. X
  320. X    /* close the output file */
  321. X    ad_close();
  322. X}
  323. X
  324. X/* getvalue - get a value */
  325. Xint getvalue()
  326. X{
  327. X    SYMBOL *sym;
  328. X
  329. X    switch (token()) {
  330. X    case T_IDENTIFIER:    if (sym = sfind(t_token))
  331. X                return (sym->s_value);
  332. X            return (oenter(t_token));
  333. X    case T_NUMBER:    return (t_value);
  334. X    case T_STRING:    return (t_value);
  335. X    default:        error("Expecting identifier, number or string");
  336. X            return (0);
  337. X    }
  338. X}
  339. X
  340. X/* dalloc - allocate data space */
  341. Xint dalloc(size)
  342. X  int size;
  343. X{
  344. X    if ((dptr += size) > DMAX)
  345. X    fail("out of data space");
  346. X    return (dptr - size);
  347. X}
  348. X
  349. X/* add_word - add a word to the dictionary */
  350. Xint add_word(str,type)
  351. X  char *str; int type;
  352. X{
  353. X    if ((curwrd = tfind(words,str)) == NIL) {
  354. X    if (wcnt < WMAX) {
  355. X        curwrd = ++wcnt;
  356. X        wtable[curwrd] = type;
  357. X        tenter(words,str);
  358. X    }
  359. X    else {
  360. X        error("too many words");
  361. X        curwrd = 0;
  362. X    }
  363. X    }
  364. X    else if (wtable[curwrd] == WT_UNKNOWN)
  365. X    wtable[curwrd] = type;
  366. X    else if (type != WT_UNKNOWN && type != wtable[curwrd])
  367. X    error("Ambiguous word type");
  368. X    return (curwrd);
  369. X}
  370. X
  371. X/* add_synonym - add a synonym to a word */
  372. Xint add_synonym(str,wrd)
  373. X  char *str; int wrd;
  374. X{
  375. X    curwrd = wrd;
  376. X    return (tenter(words,str));
  377. X}
  378. X
  379. X/* getword - get a word from an object field */
  380. Xint getword(off)
  381. X  int off;
  382. X{
  383. X    return ((data[off] & 0xFF) | (data[off+1] << 8));
  384. X}
  385. X
  386. X/* putword - put a word into an object field */
  387. Xputword(off,dat)
  388. X  int off,dat;
  389. X{
  390. X    data[off] = dat;
  391. X    data[off+1] = dat >> 8;
  392. X}
  393. X
  394. X/* getbyte - get a byte from an object field */
  395. Xint getbyte(off)
  396. X  int off;
  397. X{
  398. X    return (data[off]);
  399. X}
  400. X
  401. X/* putbyte - put a byte into an object field */
  402. Xputbyte(off,dat)
  403. X  int off,dat;
  404. X{
  405. X    data[off] = dat;
  406. X}
  407. X
  408. X/* output - output the binary data structures */
  409. Xoutput()
  410. X{
  411. X    int woff,wsize;    /* word table offset and size */
  412. X    int ooff,osize;    /* object table offset and size */
  413. X    int aoff,asize;    /* action table offset and size */
  414. X    int toff,tsize;    /* word type table offset and size */
  415. X    int voff,vsize;    /* variable table offset and size */
  416. X    int soff,ssize;    /* save area offset and size */
  417. X    int dsize;        /* data size without dictionary */
  418. X    int dbase,cbase,size,mblk,dblk,i;
  419. X
  420. X    /* make sure the adventure id information is present */
  421. X    if (aname[0] == 0) {
  422. X    xerror("no adventure identification information");
  423. X    strcpy(aname,"ADVENTURE");
  424. X    aversion = 0;
  425. X    }
  426. X
  427. X    /* pad the remainder of this message block */
  428. X    while (msgoff & 0x007F)
  429. X    { ad_putc('\0'); ad_putc('\0'); ad_putc('\0'); ad_putc('\0'); msgoff++; }
  430. X
  431. X    /* save the size of the data area before the dictionary */
  432. X    dsize = dptr;
  433. X
  434. X    /* insert the vocabulary into the data array */
  435. X    woutput(words->tr_root);
  436. X
  437. X    /* compute table offsets */
  438. X    woff = 0;            wsize = tentries(words) * 2 + 2;
  439. X    toff = woff + wsize; tsize = wcnt;
  440. X    ooff = toff + tsize; osize = ocnt * 2 + 2;
  441. X    aoff = ooff + osize; asize = acnt * 2 + 2;
  442. X    voff = aoff + asize; vsize = vcnt * 2 + 2;
  443. X    dbase = voff + vsize;
  444. X    cbase = dbase + dptr;
  445. X
  446. X    /* compute the resident structure size */
  447. X    size = wsize+tsize+osize+asize+vsize+dptr+cptr;
  448. X
  449. X    /* set the save area parameters */
  450. X    soff = voff; ssize = vsize + dsize;
  451. X
  452. X    /* compute the first block for message text */
  453. X    mblk = 1;
  454. X    dblk = (int)(ad_foff >> 9);
  455. X
  456. X    /* output the word table */
  457. X    word_out(tentries(words));
  458. X    wtoutput(words->tr_root);
  459. X
  460. X    /* output the word type table */
  461. X    for (i = 1; i <= wcnt; i++)
  462. X    byte_out(wtable[i]);
  463. X
  464. X    /* output the object table */
  465. X    word_out(ocnt);
  466. X    for (i = 1; i <= ocnt; i++) {
  467. X    if (otable[i] == NIL)
  468. X        undef_object(i);
  469. X    word_out(otable[i]);
  470. X    }
  471. X
  472. X    /* output the action table */
  473. X    word_out(acnt);
  474. X    for (i = 1; i <= acnt; i++)
  475. X    word_out(atable[i]);
  476. X
  477. X    /* beginning of saveable data */
  478. X
  479. X    /* output the variable table */
  480. X    word_out(vcnt);
  481. X    for (i = 1; i <= vcnt; i++)
  482. X    word_out(NIL);
  483. X
  484. X    /* output the data space */
  485. X    for (i = 0; i < dptr; )
  486. X    byte_out(data[i++]);
  487. X
  488. X    /* end of saveable data */
  489. X
  490. X    /* output the code space */
  491. X    for (i = 0; i < cptr; )
  492. X    byte_out(code[i++]);
  493. X
  494. X    /* output the file header */
  495. X    ad_seek(0L);
  496. X    word_out(size);    /* resident structure size */
  497. X    str_out("ADVSYS",6);/* magic information */
  498. X    word_out(VERSION);    /* data structure version number */
  499. X    str_out(aname,18);    /* adventure name */
  500. X    word_out(aversion);    /* adventure version number */
  501. X    word_out(woff);    /* word table offset */
  502. X    word_out(toff);    /* word type table offset */
  503. X    word_out(ooff);    /* object table offset */
  504. X    word_out(aoff);    /* action table offset */
  505. X    word_out(voff);    /* variable table offset */
  506. X    word_out(dbase);    /* base of data */
  507. X    word_out(cbase);    /* base of code */
  508. X    word_out(dblk);    /* first data block */
  509. X    word_out(mblk);    /* first message text block */
  510. X    word_out(h_init);    /* initialization code */
  511. X    word_out(h_update);    /* update code */
  512. X    word_out(h_before);    /* before handler code */
  513. X    word_out(h_after);    /* after handler code */
  514. X    word_out(h_error);    /* error handling code */
  515. X    word_out(soff);    /* save area offset */
  516. X    word_out(ssize);    /* save area size */
  517. X
  518. X    /* show statistics */
  519. X    printf("[ words:      %d ]\n",tentries(words));
  520. X    printf("[ word types: %d ]\n",wcnt);
  521. X    printf("[ objects:    %d ]\n",ocnt);
  522. X    printf("[ actions:    %d ]\n",acnt);
  523. X    printf("[ variables:  %d ]\n",vcnt);
  524. X    printf("[ data:       %d ]\n",dsize);
  525. X    printf("[ code:       %d ]\n",cptr);
  526. X    printf("[ dictionary: %d ]\n",dptr-dsize);
  527. X    printf("[ text:       %ld ]\n",(long) msgoff * 4L);
  528. X    printf("[ save area:  %d ]\n",ssize);
  529. X    printf("[ errors:     %d ]\n",errcount);
  530. X#ifdef MAC
  531. X    macpause();
  532. X#endif
  533. X}
  534. X
  535. X/* woutput - output the word data */
  536. Xwoutput(node)
  537. X  TNODE *node;
  538. X{
  539. X    int wnum,wrd;
  540. X
  541. X    if (node) {
  542. X    woutput(LLINK(node));
  543. X    wnum = WORD(node);
  544. X    wrd = WORD(node) = dalloc(strlen(KEY(node))+3);
  545. X    putword(wrd,wnum);
  546. X    strcpy(data+wrd+2,KEY(node));
  547. X    if (wtable[wnum] == WT_UNKNOWN)
  548. X        printf("Type of word %s is unknown\n",KEY(node));
  549. X    woutput(RLINK(node));
  550. X    }
  551. X}
  552. X
  553. X/* wtoutput - output the word table */
  554. Xwtoutput(node)
  555. X  TNODE *node;
  556. X{
  557. X    if (node) {
  558. X    wtoutput(LLINK(node));
  559. X    word_out(WORD(node));
  560. X    wtoutput(RLINK(node));
  561. X    }
  562. X}
  563. X
  564. X/* undef_object - complain about an undefined object */
  565. Xundef_object(n)
  566. X  int n;
  567. X{
  568. X    char msg[100];
  569. X    SYMBOL *sym;
  570. X
  571. X    for (sym = symbols; sym != NULL; sym = sym->s_next)
  572. X    if (sym->s_type == ST_OBJECT && n == sym->s_value) {
  573. X        sprintf(msg,"Object %s is undefined",sym->s_name);
  574. X        xerror(msg);
  575. X        break;
  576. X    }
  577. X}
  578. X
  579. X/* str_out - output a string */
  580. Xstr_out(str,len)
  581. X  char *str; int len;
  582. X{
  583. X    while (len--)
  584. X    byte_out(*str++);
  585. X}
  586. X
  587. X/* word_out - output a word */
  588. Xword_out(dat)
  589. X  int dat;
  590. X{
  591. X    byte_out(dat);
  592. X    byte_out(dat >> 8);
  593. X}
  594. X
  595. X/* byte_out - output a byte */
  596. Xbyte_out(dat)
  597. X  int dat;
  598. X{
  599. X    ad_putc((~dat - 30) & 0xFF);
  600. X}
  601. X
  602. X/* oenter - enter an object into the symbol table */
  603. Xint oenter(name)
  604. X  char *name;
  605. X{
  606. X    SYMBOL *sym;
  607. X
  608. X    if (sym = sfind(name)) {
  609. X    if (sym->s_type != ST_OBJECT)
  610. X        error("Not an object");
  611. X    return (sym->s_value);
  612. X    }
  613. X    if (ocnt < OMAX) {
  614. X        senter(name,ST_OBJECT,++ocnt);
  615. X        otable[ocnt] = NIL;
  616. X    }
  617. X    else
  618. X    error("too many objects");
  619. X    return (ocnt);
  620. X}
  621. X
  622. X/* ofind - find an object in the symbol table */
  623. Xint ofind(name)
  624. X  char *name;
  625. X{
  626. X    SYMBOL *sym;
  627. X
  628. X    if (sym = sfind(name)) {
  629. X    if (sym->s_type != ST_OBJECT)
  630. X        return (NIL);
  631. X    return (sym->s_value);
  632. X    }
  633. X    return (NIL);
  634. X}
  635. X
  636. X/* aenter - enter an action into the symbol table */
  637. Xint aenter(name)
  638. X  char *name;
  639. X{
  640. X    SYMBOL *sym;
  641. X
  642. X    if (sym = sfind(name)) {
  643. X    if (sym->s_type != ST_ACTION)
  644. X        error("Not an action");
  645. X    return (sym->s_value);
  646. X    }
  647. X    if (acnt < AMAX) {
  648. X        senter(name,ST_ACTION,++acnt);
  649. X        atable[acnt] = NIL;
  650. X    }
  651. X    else
  652. X    error("too many actions");
  653. X    return (acnt);
  654. X}
  655. X
  656. X/* venter - enter a variable into the symbol table */
  657. Xint venter(name)
  658. X  char *name;
  659. X{
  660. X    SYMBOL *sym;
  661. X
  662. X    if (sym = sfind(name)) {
  663. X    if (sym->s_type != ST_VARIABLE)
  664. X        error("Not a variable");
  665. X    return (sym->s_value);
  666. X    }
  667. X    senter(name,ST_VARIABLE,++vcnt);
  668. X    return (vcnt);
  669. X}
  670. X
  671. X/* penter - enter a property into the symbol table */
  672. Xint penter(name)
  673. X  char *name;
  674. X{
  675. X    SYMBOL *sym;
  676. X
  677. X    if (sym = sfind(name)) {
  678. X    if (sym->s_type != ST_PROPERTY)
  679. X        error("Not a property");
  680. X    return (sym->s_value);
  681. X    }
  682. X    senter(name,ST_PROPERTY,++pcnt);
  683. X    return (pcnt);
  684. X}
  685. X
  686. X/* center - enter a constant into the symbol table */
  687. Xcenter(name,value)
  688. X  char *name; int value;
  689. X{
  690. X    if (sfind(name)) {
  691. X    error("Already defined");
  692. X    return;
  693. X    }
  694. X    senter(name,ST_CONSTANT,value);
  695. X}
  696. X
  697. X/* sfind - find a symbol in the symbol table */
  698. XSYMBOL *sfind(name)
  699. X  char *name;
  700. X{
  701. X    SYMBOL *sym;
  702. X
  703. X    for (sym = symbols; sym != NULL; sym = sym->s_next)
  704. X    if (strcmp(name,sym->s_name) == 0)
  705. X        break;
  706. X    return (sym);
  707. X}
  708. X
  709. X/* senter - enter a symbol into the symbol table */
  710. XSYMBOL *senter(name,type,value)
  711. X  char *name; int type,value;
  712. X{
  713. X    SYMBOL *sym;
  714. X
  715. X    if ((sym = (SYMBOL *)malloc(sizeof(SYMBOL))) == NULL)
  716. X    fail("out of memory");
  717. X    sym->s_name = save(name);
  718. X    sym->s_type = type;
  719. X    sym->s_value = value;
  720. X    sym->s_next = symbols;
  721. X    symbols = sym;
  722. X    return (sym);
  723. X}
  724. X
  725. X/* frequire - fetch a token and check it */
  726. Xfrequire(rtkn)
  727. X  int rtkn;
  728. X{
  729. X    require(token(),rtkn);
  730. X}
  731. X
  732. X/* require - check for a required token */
  733. Xrequire(tkn,rtkn)
  734. X  int tkn,rtkn;
  735. X{
  736. X    char msg[100];
  737. X    if (tkn != rtkn) {
  738. X    sprintf(msg,"Expecting %s",t_names[rtkn]);
  739. X    error(msg);
  740. X    }
  741. X}
  742. X
  743. X/* save - allocate memory for a string */
  744. Xchar *save(str)
  745. X  char *str;
  746. X{
  747. X    char *new;
  748. X
  749. X    if ((new = malloc(strlen(str)+1)) == NULL)
  750. X    fail("out of memory");
  751. X    strcpy(new,str);
  752. X    return (new);
  753. X}
  754. X
  755. X/* match - compare a string with the current token */
  756. Xint match(str)
  757. X  char *str;
  758. X{
  759. X    return (strcmp(str,t_token) == 0);
  760. X}
  761. X
  762. X/* fail - print an error message and exit */
  763. Xfail(msg)
  764. X  char *msg;
  765. X{
  766. X    printf("%s\n",msg);
  767. X#ifdef MAC
  768. X    macpause();
  769. X#endif
  770. X    exit();
  771. X}
  772. X
  773. END_OF_advcom.c
  774. if test 14821 -ne `wc -c <advcom.c`; then
  775.     echo shar: \"advcom.c\" unpacked with wrong size!
  776. fi
  777. # end of overwriting check
  778. fi
  779. if test -f advint.h -a "${1}" != "-c" ; then 
  780.   echo shar: Will not over-write existing file \"advint.h\"
  781. else
  782. echo shar: Extracting \"advint.h\" \(362 characters\)
  783. sed "s/^X//" >advint.h <<'END_OF_advint.h'
  784. X
  785. X/* advint.h - adventure interpreter definitions */
  786. X/*
  787. X    Copyright (c) 1986, by David Michael Betz
  788. X    All rights reserved
  789. X*/
  790. X
  791. X#include <stdio.h>
  792. X#include <ctype.h>
  793. X
  794. X/* useful definitions */
  795. X#define TRUE        1
  796. X#define FALSE        0
  797. X#define EOS        '\0'
  798. X
  799. X/* program limits */
  800. X#define STKSIZE        500
  801. X
  802. X/* code completion codes */
  803. X#define FINISH        1
  804. X#define CHAIN        2
  805. X#define ABORT        3
  806. END_OF_advint.h
  807. if test 362 -ne `wc -c <advint.h`; then
  808.     echo shar: \"advint.h\" unpacked with wrong size!
  809. fi
  810. # end of overwriting check
  811. fi
  812. if test -f advscn.c -a "${1}" != "-c" ; then 
  813.   echo shar: Will not over-write existing file \"advscn.c\"
  814. else
  815. echo shar: Extracting \"advscn.c\" \(6037 characters\)
  816. sed "s/^X//" >advscn.c <<'END_OF_advscn.c'
  817. X
  818. X/* advscn.c - a lexical scanner for the adventure compiler */
  819. X/*
  820. X    Copyright (c) 1986, by David Michael Betz
  821. X    All rights reserved
  822. X*/
  823. X
  824. X#include "advcom.h"
  825. X
  826. X/* useful definitions */
  827. X#define maplower(ch)    (isupper(ch) ? tolower(ch) : ch)
  828. X
  829. X/* global variables */
  830. Xint errcount=0;        /* error count */
  831. Xint t_value;        /* numeric value */
  832. Xchar t_token[TKNSIZE+1];/* token string */
  833. Xchar *t_names[] = {
  834. X    0,
  835. X    "(",
  836. X    ")",
  837. X    "STRING",
  838. X    "IDENTIFIER",
  839. X    "NUMBER",
  840. X    "EOF"
  841. X};
  842. X
  843. X/* external variables */
  844. Xextern FILE *ifp;    /* input file pointer */
  845. Xextern int msgoff;    /* message section offset */
  846. X
  847. X/* local variables */
  848. Xstatic int savetkn = 0;    /* look ahead token */
  849. Xstatic int savech = 0;    /* look ahead character */
  850. Xstatic char fname[200];    /* include file name */
  851. Xstatic char line[200];    /* current input line */
  852. Xstatic char *lptr;    /* line pointer */
  853. Xstatic int lnum;    /* line number */
  854. Xstatic int ieof;    /* input end of file flag */
  855. Xstatic int save_lnum;    /* saved lnum */
  856. Xstatic FILE *save_ifp;    /* saved ifp */
  857. Xstatic int scnt;    /* count of characters in string */
  858. X
  859. X/* sinit - initialize the scanner */
  860. Xsinit()
  861. X{
  862. X    /* setup the line buffer */
  863. X    lptr = line; *lptr = 0;
  864. X    lnum = 0;
  865. X
  866. X    /* no include file yet */
  867. X    save_ifp = NULL;
  868. X
  869. X    /* no lookahead yet */
  870. X    savech = 0;
  871. X    savetkn = 0;
  872. X
  873. X    /* not eof yet */
  874. X    ieof = FALSE;
  875. X}
  876. X
  877. X/* token - get the next token */
  878. Xint token()
  879. X{
  880. X    int tkn;
  881. X
  882. X    if (tkn = savetkn)
  883. X    savetkn = 0;
  884. X    else
  885. X    tkn = rtoken();
  886. X    return (tkn);
  887. X}
  888. X
  889. X/* stoken - save a token */
  890. Xstoken(tkn)
  891. X  int tkn;
  892. X{
  893. X    savetkn = tkn;
  894. X}
  895. X
  896. X/* rtoken - read the next token */
  897. Xint rtoken()
  898. X{
  899. X    int ch;
  900. X
  901. X    /* check the next character */
  902. X    for (;;)
  903. X    switch (ch = skipspaces()) {
  904. X    case EOF:    return (T_EOF);
  905. X    case '(':    strcpy(t_token,"("); return (T_OPEN);
  906. X    case ')':    strcpy(t_token,")"); return (T_CLOSE);
  907. X    case '"':    return (getstring());
  908. X    case ';':    while (getch() != '\n'); break;
  909. X    default:    return (getid(ch));
  910. X    }
  911. X}
  912. X
  913. X/* getstring - get a string */
  914. Xint getstring()
  915. X{
  916. X    int ch,sflag;
  917. X
  918. X    t_value = msgoff;
  919. X    sflag = FALSE;
  920. X    scnt = 0;
  921. X    while ((ch = getch()) != EOF && ch != '"')
  922. X    if (isspace(ch))
  923. X        sflag = TRUE;
  924. X    else {
  925. X        if (ch == '\\')
  926. X        switch (ch = getch()) {
  927. X        case 'n':  ch = '\n'; break;
  928. X        case 't':  ch = '\t'; break;
  929. X        }
  930. X        if (sflag)
  931. X        { wputc(' '); sflag = FALSE; }
  932. X        wputc(ch);
  933. X    }
  934. X    if (sflag)
  935. X    wputc(' ');
  936. X    strdone();
  937. X    strcpy(t_token,"{string}");
  938. X    return (T_STRING);
  939. X}
  940. X
  941. X/* getid - get an identifier */
  942. Xint getid(ch)
  943. X  int ch;
  944. X{
  945. X    char *p;
  946. X
  947. X    p = t_token; *p++ = maplower(ch);
  948. X    while ((ch = getch()) != EOF && isidchar(ch))
  949. X    *p++ = maplower(ch);
  950. X    *p = EOS;
  951. X    savech = ch;
  952. X    return (isnumber(t_token,&t_value) ? T_NUMBER : T_IDENTIFIER);
  953. X}
  954. X
  955. X/* isnumber - check if this string is a number */
  956. Xint isnumber(str,pval)
  957. X  char *str; int *pval;
  958. X{
  959. X    int digits;
  960. X    char *p;
  961. X
  962. X    /* initialize */
  963. X    p = str; digits = 0;
  964. X
  965. X    /* check for a sign */
  966. X    if (*p == '+' || *p == '-')
  967. X    p++;
  968. X
  969. X    /* check for a string of digits */
  970. X    while (isdigit(*p))
  971. X    p++, digits++;
  972. X
  973. X    /* make sure there was at least one digit and this is the end */
  974. X    if (digits == 0 || *p)
  975. X    return (FALSE);
  976. X
  977. X    /* convert the string to an integer and return successfully */
  978. X    if (*str == '+') ++str;
  979. X    *pval = atoi(str);
  980. X    return (TRUE);
  981. X}
  982. X
  983. X/* wputc - put a character into the output file */
  984. Xwputc(ch)
  985. X  int ch;
  986. X{
  987. X    ad_putc(encode(ch));
  988. X    scnt++;
  989. X}
  990. X
  991. X/* strdone - finish a string */
  992. Xstrdone()
  993. X{
  994. X    wputc('\0');
  995. X    while (scnt & 3)
  996. X    wputc('\0');
  997. X    msgoff += scnt >> 2;
  998. X}
  999. X
  1000. X/* skipspaces - skip leading spaces */
  1001. Xskipspaces()
  1002. X{
  1003. X    int ch;
  1004. X
  1005. X    while ((ch = getch()) && isspace(ch))
  1006. X    ;
  1007. X    return (ch);
  1008. X}
  1009. X
  1010. X/* isidchar - is this an identifier character */
  1011. Xint isidchar(ch)
  1012. X  int ch;
  1013. X{
  1014. X    return (!isspace(ch) && ch != '(' && ch != ')' && ch != '"');
  1015. X}
  1016. X
  1017. X/* getch - get the next character */
  1018. Xint getch()
  1019. X{
  1020. X    FILE *fp;
  1021. X    int ch;
  1022. X
  1023. X    /* check for a lookahead character */
  1024. X    if (ch = savech)
  1025. X    savech = 0;
  1026. X
  1027. X    /* check for a buffered character */
  1028. X    else if (ch = *lptr)
  1029. X    lptr++;
  1030. X
  1031. X    /* check for end of file */
  1032. X    else if (ieof)
  1033. X    ch = EOF;
  1034. X
  1035. X    /* read another line */
  1036. X    else {
  1037. X
  1038. X    /* read the line */
  1039. X    for (lptr = line; (ch = getchr()) != EOF && (*lptr++ = ch) != '\n';)
  1040. X        ;
  1041. X    *lptr = 0;
  1042. X    lnum++;
  1043. X
  1044. X    /* check for an included file */
  1045. X    if (line[0] == '@') {
  1046. X
  1047. X        /* open the file */
  1048. X        strcpy(fname,&line[1]); fname[strlen(fname)-1] = 0;
  1049. X        if ((fp = fopen(fname,"r")) == NULL) {
  1050. X        printf("Can't open include file: %s\n",fname);
  1051. X        exit();
  1052. X        }
  1053. X        printf("[ including %s ]\n",fname);
  1054. X
  1055. X        /* setup input from the file */
  1056. X        save_lnum = lnum;
  1057. X        save_ifp = ifp;
  1058. X        ifp = fp;
  1059. X
  1060. X        /* setup for the first line */
  1061. X        lptr = line; *lptr = 0;
  1062. X        lnum = 0;
  1063. X    }
  1064. X
  1065. X    /* otherwise this must be an input line */
  1066. X    else {
  1067. X
  1068. X        /* terminate the line with a newline */
  1069. X        *lptr++ = '\n'; *lptr = 0;
  1070. X
  1071. X        /* check for end of file */
  1072. X        if (ch == EOF)
  1073. X        ieof = TRUE;
  1074. X
  1075. X        /* update the line number and setup for the new line */
  1076. X        lptr = line;
  1077. X    }
  1078. X
  1079. X    /* get a character */
  1080. X    ch = getch();
  1081. X    }
  1082. X
  1083. X    /* return the current character */
  1084. X    return (ch);
  1085. X}
  1086. X
  1087. X/* getchr - get a character checking for end of file */
  1088. Xint getchr()
  1089. X{
  1090. X    int ch;
  1091. X
  1092. X    if ((ch = getc(ifp)) == EOF || ch == '\032') {
  1093. X    if (save_ifp) {
  1094. X        printf("[ end of %s ]\n",fname);
  1095. X        fclose(ifp);
  1096. X        lnum = save_lnum;
  1097. X        ifp = save_ifp;
  1098. X        save_ifp = NULL;
  1099. X        ch = getchr();
  1100. X    }
  1101. X    else
  1102. X        ch = EOF;
  1103. X    }
  1104. X    else if (ch == '\r')
  1105. X    ch = getchr();
  1106. X    return (ch);
  1107. X}
  1108. X
  1109. X/* encode - encode a single character */
  1110. Xint encode(ch)
  1111. X  int ch;
  1112. X{
  1113. X    return ((ch - 30) & 0xFF);
  1114. X}
  1115. X
  1116. X/* error - report an error in the current line */
  1117. Xerror(msg)
  1118. X  char *msg;
  1119. X{
  1120. X    char *p;
  1121. X
  1122. X    printf(">>> %s <<<\n>>> in line %d <<<\n%s",msg,lnum,line);
  1123. X    for (p = line; p < lptr; p++)
  1124. X    if (*p == '\t')
  1125. X        putchar('\t');
  1126. X    else
  1127. X        putchar(' ');
  1128. X    printf("^\n");
  1129. X    errcount++;
  1130. X#ifdef MAC
  1131. X    macpause();
  1132. X#endif
  1133. X}
  1134. X
  1135. X/* xerror - report an error in the current line */
  1136. Xxerror(msg)
  1137. X  char *msg;
  1138. X{
  1139. X    printf(">>> %s <<<\n",msg);
  1140. X    errcount++;
  1141. X}
  1142. END_OF_advscn.c
  1143. if test 6037 -ne `wc -c <advscn.c`; then
  1144.     echo shar: \"advscn.c\" unpacked with wrong size!
  1145. fi
  1146. # end of overwriting check
  1147. fi
  1148. if test -f advsys.doc -a "${1}" != "-c" ; then 
  1149.   echo shar: Will not over-write existing file \"advsys.doc\"
  1150. else
  1151. echo shar: Extracting \"advsys.doc\" \(29358 characters\)
  1152. sed "s/^X//" >advsys.doc <<'END_OF_advsys.doc'
  1153. X
  1154. X
  1155. X
  1156. X
  1157. X
  1158. X
  1159. X
  1160. X                      ADVSYS - An Adventure Writing System
  1161. X
  1162. X                                  Version 1.2
  1163. X
  1164. X                                 by David Betz
  1165. X                              114 Davenport Avenue
  1166. X                              Manchester, NH 03103
  1167. X                             (603) 625-4691 (home)
  1168. X
  1169. X                                 July 14, 1986
  1170. X
  1171. X                       Copyright (c) 1986, by David Betz
  1172. X                              All Rights Reserved
  1173. X        Permission is hereby granted for unrestricted non-commercial use
  1174. X
  1175. X
  1176. X
  1177. X
  1178. X
  1179. X
  1180. X
  1181. X
  1182. X
  1183. X
  1184. X
  1185. X
  1186. X
  1187. X
  1188. X
  1189. X
  1190. X
  1191. X
  1192. X
  1193. X
  1194. X
  1195. X
  1196. X
  1197. X
  1198. X
  1199. X
  1200. X
  1201. X
  1202. X
  1203. X
  1204. X
  1205. X
  1206. X
  1207. X
  1208. X
  1209. X
  1210. X
  1211. X
  1212. X
  1213. X
  1214. X
  1215. X
  1216. X
  1217. X
  1218. X
  1219. X
  1220. X
  1221. X
  1222. X
  1223. X        ADVSYS            An Adventure Writing System             Page 2
  1224. X
  1225. X
  1226. X        INTRODUCTION
  1227. X
  1228. X        ADVSYS is a special purpose programming language that was
  1229. X        specifically designed to be used to write computer text
  1230. X        adventure games.  It includes a facility for defining the kinds
  1231. X        of objects that are common in adventures.  Some objects
  1232. X        represent locations on the game map, some objects represent
  1233. X        things that the player can find while exploring the adventure
  1234. X        world, and some objects represent other characters that the
  1235. X        adventurer can encounter during his or her journeys.  The
  1236. X        adventure language also provides a facility to define actions.
  1237. X        Actions are short sections of code that determine what happens
  1238. X        in response to a command from the player.  These two concepts,
  1239. X        "objects" and "actions" form the basis for the adventure
  1240. X        language.
  1241. X
  1242. X
  1243. X        ACKNOWLEDGEMENTS
  1244. X
  1245. X        Although I have written all of the code associated with this
  1246. X        adventure writing system, I must acknowledge the assistance of
  1247. X        one individual without whom this project would probably never
  1248. X        have reached completion.  That person is Gary McGath.  Gary was
  1249. X        interested in writing a commercial quality adventure game and I
  1250. X        convinced him to write it using my system (which was as yet
  1251. X        almost completely unspecified) instead of using a traditional
  1252. X        programming language.  The input that Gary provided during the
  1253. X        development of his game contributed significantly to the overall
  1254. X        design of the system.  I would like to thank Gary for that
  1255. X        contribution.
  1256. X
  1257. X
  1258. X
  1259. X
  1260. X
  1261. X
  1262. X
  1263. X
  1264. X
  1265. X
  1266. X
  1267. X
  1268. X
  1269. X
  1270. X
  1271. X
  1272. X
  1273. X
  1274. X
  1275. X
  1276. X
  1277. X
  1278. X
  1279. X
  1280. X
  1281. X
  1282. X
  1283. X
  1284. X
  1285. X
  1286. X
  1287. X
  1288. X
  1289. X        ADVSYS            An Adventure Writing System             Page 3
  1290. X
  1291. X
  1292. X        USING THE SYSTEM TO WRITE AN ADVENTURE
  1293. X
  1294. X        In order to write an adventure using this system, you need to
  1295. X        write an adventure description.  This is an ordinary ASCII text
  1296. X        file containing definitions for all of the objects and actions
  1297. X        in your adventure game.  This file is used as input to the
  1298. X        adventure compiler.  The compiler takes the adventure
  1299. X        description and compiles it into a set of data structures.
  1300. X
  1301. X        In order to play an adventure written using this system, you
  1302. X        need the data structure file that was produced by the compiler
  1303. X        and the adventure interpreter program.  The interpreter uses the
  1304. X        information produced by the adventure compiler to allow a player
  1305. X        to play the adventure game.  Notice that it is not necessary for
  1306. X        the player to have access to the original adventure description
  1307. X        file.  All of the information that is necessary to play the
  1308. X        adventure game is contained within the data structure file that
  1309. X        is produced by the compiler.  This file is a binary file that
  1310. X        cannot be simply "listed" to reveal the internal workings of the
  1311. X        adventure.
  1312. X
  1313. X        The adventure compiler is called ADVCOM and the interpreter is
  1314. X        called ADVINT.  These two programs in conjunction with this
  1315. X        documentation are all that is required to write and play
  1316. X        adventure games using this system.
  1317. X
  1318. X
  1319. X
  1320. X
  1321. X
  1322. X
  1323. X
  1324. X
  1325. X
  1326. X
  1327. X
  1328. X
  1329. X
  1330. X
  1331. X
  1332. X
  1333. X
  1334. X
  1335. X
  1336. X
  1337. X
  1338. X
  1339. X
  1340. X
  1341. X
  1342. X
  1343. X
  1344. X
  1345. X
  1346. X
  1347. X
  1348. X
  1349. X
  1350. X
  1351. X
  1352. X
  1353. X
  1354. X
  1355. X        ADVSYS            An Adventure Writing System             Page 4
  1356. X
  1357. X
  1358. X        RUNNING THE COMPILER
  1359. X
  1360. X        If you have created an adventure definition file called
  1361. X        "MYADV.ADV", you can compile it with the command:
  1362. X
  1363. X                A>advcom myadv
  1364. X
  1365. X        Typing this command will invoke the adventure compiler and cause
  1366. X        it to compile the file named "MYADV.ADV".  The ".ADV" extension
  1367. X        is added to the file name by the compiler.  During the process
  1368. X        of compiling the file, many messages will be printed telling
  1369. X        about the progress of the compiler.  At the end of the
  1370. X        compilation process, the compiler prints a set of statistics
  1371. X        describing the resulting data structure file.  This file will be
  1372. X        called "MYADV.DAT".  It contains the data structures needed by
  1373. X        the adventure interpreter to allow a player to play the
  1374. X        adventure game.
  1375. X
  1376. X        Note: The "A>" in the line above is the MS-DOS prompt and should
  1377. X        not be typed as part of the command.
  1378. X
  1379. X
  1380. X        RUNNING THE INTERPRETER
  1381. X
  1382. X        Assuming that you have a compiled adventure data file called
  1383. X        "MYADV.DAT", you can play the adventure by typing the command:
  1384. X
  1385. X                A>advint myadv
  1386. X
  1387. X        This command will start the adventure.  There will probably be
  1388. X        some text printed at this point describing the adventure and the
  1389. X        initial situation.  You will then be prompted to type a command.
  1390. X        The prompt is the colon character.  The format for commands is
  1391. X        described under the section about the parser.  After typing a
  1392. X        command, you will be told what happened as a result of your
  1393. X        command, your new situation will be described and you will begin
  1394. X        the loop again.
  1395. X
  1396. X
  1397. X
  1398. X
  1399. X
  1400. X
  1401. X
  1402. X
  1403. X
  1404. X
  1405. X
  1406. X
  1407. X
  1408. X
  1409. X
  1410. X
  1411. X
  1412. X
  1413. X
  1414. X
  1415. X
  1416. X
  1417. X
  1418. X
  1419. X
  1420. X
  1421. X        ADVSYS            An Adventure Writing System             Page 5
  1422. X
  1423. X
  1424. X        ADVENTURE DESCRIPTION FILE FORMAT
  1425. X
  1426. X            All adventure description files contain a collection of
  1427. X            statements.  These statements must be formed according to
  1428. X            the following rules:
  1429. X
  1430. X
  1431. X        The adventure definition statement:
  1432. X
  1433. X            All adventure definitions should have an ADVENTURE
  1434. X            statement.  This statement gives the name of the adventure
  1435. X            and the version number of the definition file.  Each
  1436. X            adventure should have a unique name.  This name is used to
  1437. X            identify "saved position" files and insure that only files
  1438. X            that correspond to the current adventure are restored.  The
  1439. X            version number allows the author to have many versions of
  1440. X            the same adventure during development and guarantee that
  1441. X            "save" files from one version aren't restored into another
  1442. X            version.
  1443. X
  1444. X              (ADVENTURE name version)
  1445. X
  1446. X          Example:
  1447. X
  1448. X              (ADVENTURE sample 1)
  1449. X
  1450. X
  1451. X        Vocabulary statements:
  1452. X
  1453. X            These statements add words to the adventure vocabulary.
  1454. X
  1455. X              (ADJECTIVE word*)
  1456. X              (PREPOSITION word*)
  1457. X              (CONJUNCTION word*)
  1458. X              (ARTICLE word*)
  1459. X              (SYNONYM word synonym*)
  1460. X
  1461. X          Examples:
  1462. X
  1463. X              (ADJECTIVE red blue)
  1464. X              (CONJUNCTION and)
  1465. X              (SYNONYM big large)
  1466. X
  1467. X          Note:
  1468. X
  1469. X              Words are also added to the vocabulary by the object
  1470. X              and action definitions using the NOUN, ADJECTIVE, VERB
  1471. X              and PREPOSITION statements.
  1472. X
  1473. X
  1474. X
  1475. X
  1476. X
  1477. X
  1478. X
  1479. X
  1480. X
  1481. X
  1482. X
  1483. X
  1484. X
  1485. X
  1486. X
  1487. X        ADVSYS            An Adventure Writing System             Page 6
  1488. X
  1489. X
  1490. X        Constant definition statement:
  1491. X
  1492. X              (DEFINE name value)
  1493. X
  1494. X          Examples:
  1495. X
  1496. X              (DEFINE what "I don't understand what you're saying!\\n")
  1497. X              (DEFINE max-load 100)
  1498. X
  1499. X
  1500. X        Function definition statement:
  1501. X
  1502. X              (DEFINE (function-name [arg-name]* [&aux tmp-name*]) expr*)
  1503. X
  1504. X          Example:
  1505. X
  1506. X              (DEFINE (factorial n)
  1507. X                (IF (< n 2)
  1508. X                  1
  1509. X                  (* n (factorial (- n 1)))))
  1510. X
  1511. X
  1512. X        Variable definition statement:
  1513. X
  1514. X              (VARIABLE variable-name*)
  1515. X
  1516. X          Example:
  1517. X
  1518. X              (VARIABLE score i j)
  1519. X
  1520. X
  1521. X        Property name definition statement:
  1522. X
  1523. X              (PROPERTY property-name*)
  1524. X
  1525. X          Example:
  1526. X
  1527. X              (PROPERTY weight value)
  1528. X
  1529. X
  1530. X
  1531. X
  1532. X
  1533. X
  1534. X
  1535. X
  1536. X
  1537. X
  1538. X
  1539. X
  1540. X
  1541. X
  1542. X
  1543. X
  1544. X
  1545. X
  1546. X
  1547. X
  1548. X
  1549. X
  1550. X
  1551. X
  1552. X
  1553. X        ADVSYS            An Adventure Writing System             Page 7
  1554. X
  1555. X
  1556. X        Comments:
  1557. X
  1558. X            Comments begin with a semi-colon and end with the end of the
  1559. X            line.
  1560. X
  1561. X          Example:
  1562. X
  1563. X              ; this is a comment
  1564. X
  1565. X
  1566. X        Include files:
  1567. X
  1568. X            Any line that begins with a "@" causes the inclusion of
  1569. X            another file.  The file name immediately follows the at-sign
  1570. X            and extends to the end of the line.  Only one level of
  1571. X            include is supported.
  1572. X
  1573. X          Example:
  1574. X
  1575. X              @basic.adv
  1576. X
  1577. X
  1578. X
  1579. X
  1580. X
  1581. X
  1582. X
  1583. X
  1584. X
  1585. X
  1586. X
  1587. X
  1588. X
  1589. X
  1590. X
  1591. X
  1592. X
  1593. X
  1594. X
  1595. X
  1596. X
  1597. X
  1598. X
  1599. X
  1600. X
  1601. X
  1602. X
  1603. X
  1604. X
  1605. X
  1606. X
  1607. X
  1608. X
  1609. X
  1610. X
  1611. X
  1612. X
  1613. X
  1614. X
  1615. X
  1616. X
  1617. X
  1618. X
  1619. X        ADVSYS            An Adventure Writing System             Page 8
  1620. X
  1621. X
  1622. X        Handler definition statements:
  1623. X
  1624. X              (INIT expr*)
  1625. X              (UPDATE expr*)
  1626. X              (BEFORE expr*)
  1627. X              (AFTER expr*)
  1628. X              (ERROR expr*)
  1629. X
  1630. X          Example:
  1631. X
  1632. X              (INIT
  1633. X                (print "Welcome to the sample adventure!\\n"))
  1634. X
  1635. X
  1636. X        Handlers:
  1637. X
  1638. X            All activity within an adventure game is controlled by a
  1639. X            built-in handler loop.  Each of the handlers in the loop
  1640. X            contains code that is provided by the adventure author.  The
  1641. X            sequencing from handler to handler is provided by the
  1642. X            adventure system itself.
  1643. X
  1644. X            The first handler that is called in an adventure game is the
  1645. X            INIT handler.  It prints some sort of introductory text and
  1646. X            initializes all global variables in order to start the
  1647. X            adventure game.
  1648. X
  1649. X            After the INIT handler has completed, the normal loop is
  1650. X            entered.  It starts with the UPDATE handler.  The UPDATE
  1651. X            handler prepares for the player's next turn.  It should
  1652. X            describe the player's location if it has changed since the
  1653. X            last turn.  After the UPDATE handler completes, the parser
  1654. X            is called.  It prompts the player for a command, parses the
  1655. X            command, sets the built-in parser varaibles and exits.  Then
  1656. X            the BEFORE handler is called.  It is called before the
  1657. X            action associated with the command to allow the adventure
  1658. X            author to inspect the parser variables before proceeding to
  1659. X            the action itself.  After the BEFORE handler completes, the
  1660. X            action itself is called (or whatever action is stored in the
  1661. X            built-in variable $ACTION when the BEFORE handler
  1662. X            completes).  When the action completes, the AFTER handler is
  1663. X            called to give the author a chance to handle events that
  1664. X            happen only at the end of a successful turn.  The ERROR
  1665. X            handler is called when the parser detects an error.
  1666. X
  1667. X
  1668. X
  1669. X
  1670. X
  1671. X
  1672. X
  1673. X
  1674. X
  1675. X
  1676. X
  1677. X
  1678. X
  1679. X
  1680. X
  1681. X
  1682. X
  1683. X
  1684. X
  1685. X        ADVSYS            An Adventure Writing System             Page 9
  1686. X
  1687. X
  1688. X        The handler loop:
  1689. X
  1690. X            INIT
  1691. X             |
  1692. X             v
  1693. X            UPDATE<----------+
  1694. X             |               |
  1695. X             v               |
  1696. X            parse--->ERROR---+
  1697. X             |               |
  1698. X             v               |
  1699. X            BEFORE           |
  1700. X             |               |
  1701. X             v               |
  1702. X            action           |
  1703. X             |               |
  1704. X             v               |
  1705. X            AFTER------------+
  1706. X
  1707. X
  1708. X
  1709. X
  1710. X
  1711. X
  1712. X
  1713. X
  1714. X
  1715. X
  1716. X
  1717. X
  1718. X
  1719. X
  1720. X
  1721. X
  1722. X
  1723. X
  1724. X
  1725. X
  1726. X
  1727. X
  1728. X
  1729. X
  1730. X
  1731. X
  1732. X
  1733. X
  1734. X
  1735. X
  1736. X
  1737. X
  1738. X
  1739. X
  1740. X
  1741. X
  1742. X
  1743. X
  1744. X
  1745. X
  1746. X
  1747. X
  1748. X
  1749. X
  1750. X
  1751. X        ADVSYS            An Adventure Writing System            Page 10
  1752. X
  1753. X
  1754. X        The parser:
  1755. X
  1756. X            The parser handles all commands from the player.  It prompts
  1757. X            the player when it is ready for a new command.  The prompt
  1758. X            is the colon character.  When the player has typed a
  1759. X            command, the parser breaks the command into phrases.  The
  1760. X            parser recognizes the following command forms:
  1761. X
  1762. X              [actor,] verb
  1763. X              [actor,] verb dobjects
  1764. X              [actor,] verb dobjects preposition iobject
  1765. X              [actor,] verb iobject dobjects
  1766. X
  1767. X            Where:
  1768. X
  1769. X              actor             ==> a noun phrase
  1770. X              verb              ==> the verb phrase (1 or 2 words)
  1771. X              dobjects          ==> dobject [conjunction dobject]*
  1772. X              dobject           ==> a noun phrase
  1773. X              preposition       ==> a preposition
  1774. X              iobject           ==> a noun phrase
  1775. X              noun phrase       ==> [article] [adjective]* noun
  1776. X
  1777. X           Examples:
  1778. X
  1779. X              Look
  1780. X              Take the red magic sword
  1781. X              Take the red sword and the blue bottle
  1782. X              Give the troll the red sword
  1783. X              Give the red sword to the troll
  1784. X              Troll, give me the sword
  1785. X
  1786. X           Notes:
  1787. X
  1788. X              Square brackets enclose optional phrases.  An asterisk
  1789. X              indicates zero or more of the preceeding element.
  1790. X
  1791. X              The fourth form above is treated as if the player had
  1792. X              typed:
  1793. X
  1794. X                [actor,] verb dobject "to" iobject
  1795. X
  1796. X            Once the parser has broken the command into phrases, it
  1797. X            assigns each noun phrase a number.  It stores the number of
  1798. X            the actor noun phrase in the built-in variable $ACTOR.  It
  1799. X            stores the first direct object noun phrase number in the
  1800. X            variable $DOBJECT.  It stores the number of direct objects
  1801. X            in the variable $NDOBJECTS.  It stores the indirect object
  1802. X            noun phrase number in the variable $IOBJECT.  If any of the
  1803. X            noun phrases is missing from the command, the corresponding
  1804. X            variable is set to NIL.  The parser saves the verb phrase
  1805. X            and preposition to use when determining which action to use
  1806. X            to handle the command.
  1807. X
  1808. X
  1809. X
  1810. X
  1811. X
  1812. X
  1813. X
  1814. X
  1815. X
  1816. X
  1817. X        ADVSYS            An Adventure Writing System            Page 11
  1818. X
  1819. X
  1820. X        Action definition statement:
  1821. X
  1822. X            Actions are used to handle player commands.  Each time the
  1823. X            parser finishes parsing a new command, it uses the verb
  1824. X            phrase and the preposition to locate an action to handle the
  1825. X            command.  Each action specifies a kind of template that must
  1826. X            match the command in order for the action to be called.  The
  1827. X            template consists of the words used in the verb phrase and
  1828. X            preposition and the existance of the actor, direct object
  1829. X            and indirect object noun phrases.  Once the parser finds an
  1830. X            action that matches the command, it stores the action in the
  1831. X            built-in variable $ACTION and exits.
  1832. X
  1833. X              (ACTION action-name astat*)
  1834. X                  astat:
  1835. X                      (ACTOR [flag])
  1836. X                      (VERB verb*)
  1837. X                      (DIRECT-OBJECT [flag])
  1838. X                      (PREPOSITION word*)
  1839. X                      (INDIRECT-OBJECT [flag])
  1840. X                  flag:
  1841. X                      REQUIRED  must have the corresponding np
  1842. X                      OPTIONAL  may have the corresponding np
  1843. X                      FORBIDDEN must not have the corresponding np
  1844. X                  verb:
  1845. X                      word
  1846. X                      (word word)
  1847. X
  1848. X          Example:
  1849. X
  1850. X              (ACTION take
  1851. X                (VERB take (pick up))
  1852. X                (DIRECT-OBJECT)
  1853. X                (CODE
  1854. X                  (print "You can't take the ")
  1855. X                  (print-noun $dobject)
  1856. X                  (print "!\\n")))
  1857. X
  1858. X            If the ACTOR, DIRECT-OBJECT or INDIRECT-OBJECT statements
  1859. X            are left out entirely, the settings of the corresponding
  1860. X            flags are taken from the action default definitions.  If
  1861. X            there is no action default definition, the value FORBIDDEN
  1862. X            is assumed.  If any of these statements is present, but no
  1863. X            flag is specified, it is treated as if the flag REQUIRED was
  1864. X            specified.
  1865. X
  1866. X
  1867. X
  1868. X
  1869. X
  1870. X
  1871. X
  1872. X
  1873. X
  1874. X
  1875. X
  1876. X
  1877. X
  1878. X
  1879. X
  1880. X
  1881. X
  1882. X
  1883. X        ADVSYS            An Adventure Writing System            Page 12
  1884. X
  1885. X
  1886. X        Action default definition statement:
  1887. X
  1888. X            This statement defines default values for the ACTOR, DIRECT-
  1889. X            OBJECT and INDIRECT-OBJECT flags.
  1890. X
  1891. X              (DEFAULT dstat*)
  1892. X                  dstat:
  1893. X                      (ACTOR [flag])
  1894. X                      (DIRECT-OBJECT [flag])
  1895. X                      (INDIRECT-OBJECT [flag])
  1896. X                  flag:
  1897. X                      REQUIRED
  1898. X                      OPTIONAL
  1899. X                      FORBIDDEN
  1900. X
  1901. X          Example:
  1902. X
  1903. X              (DEFAULT
  1904. X                (ACTOR OPTIONAL))
  1905. X
  1906. X
  1907. X
  1908. X
  1909. X
  1910. X
  1911. X
  1912. X
  1913. X
  1914. X
  1915. X
  1916. X
  1917. X
  1918. X
  1919. X
  1920. X
  1921. X
  1922. X
  1923. X
  1924. X
  1925. X
  1926. X
  1927. X
  1928. X
  1929. X
  1930. X
  1931. X
  1932. X
  1933. X
  1934. X
  1935. X
  1936. X
  1937. X
  1938. X
  1939. X
  1940. X
  1941. X
  1942. X
  1943. X
  1944. X
  1945. X
  1946. X
  1947. X
  1948. X
  1949. X        ADVSYS            An Adventure Writing System            Page 13
  1950. X
  1951. X
  1952. X        Object definition statements:
  1953. X
  1954. X            The object definition statements are used to define
  1955. X            individual objects and classes of objects.  The most basic
  1956. X            way of defining an object is using the (OBJECT ...)
  1957. X            statement.  This defines an object which has no parent
  1958. X            class.
  1959. X
  1960. X            It is also possible to create a class of objects that share
  1961. X            information.  A class is defined just like a normal object.
  1962. X            It is given nouns, adjectives and properties.  In addition,
  1963. X            a class may have class properties.  These are properties
  1964. X            that are shared amongst all instances of the class.  In
  1965. X            order to create an instance of a class, the (class-name ...)
  1966. X            form is used.  This creates an instance of the named class.
  1967. X            An instance will inherit all nouns and adjectives from its
  1968. X            parent class.  It will also inherit all class properties
  1969. X            defined in the parent (and its parents).  Any normal
  1970. X            properties defined in the parent class will be copied to the
  1971. X            new object.  The copies will have the same values that the
  1972. X            parent has, but it is possible for the instance to have
  1973. X            property definitions that override these values.  Instances
  1974. X            may also have additional nouns, adjectives and properties.
  1975. X
  1976. X              (OBJECT object-name ostat*)
  1977. X              (class-name object-name ostat*)
  1978. X                  ostat:
  1979. X                      (NOUN word*)
  1980. X                      (ADJECTIVE word*)
  1981. X                      (PROPERTY [property-name value]*)
  1982. X                      (CLASS-PROPERTY [property-name value]*)
  1983. X                      (METHOD (selector [arg-name]* [&aux tmp-name*])
  1984. X                          expr*)
  1985. X                  class-name:
  1986. X                      the name of a previously defined object
  1987. X
  1988. X          Examples:
  1989. X
  1990. X              (OBJECT sword
  1991. X                (NOUN sword weapon)
  1992. X                (CLASS-PROPERTY
  1993. X                  is-weapon T)
  1994. X                (PROPERTY
  1995. X                  weight 10
  1996. X                  value 5
  1997. X                  damage 20))
  1998. X
  1999. X              (sword red-sword
  2000. X                (ADJECTIVE red)
  2001. X                (PROPERTY
  2002. X                  damage 25))
  2003. X
  2004. X
  2005. X
  2006. X
  2007. X
  2008. X
  2009. X
  2010. X
  2011. X
  2012. X
  2013. X
  2014. X
  2015. X        ADVSYS            An Adventure Writing System            Page 14
  2016. X
  2017. X
  2018. X        Expressions:
  2019. X
  2020. X              (+ expr expr)     add
  2021. X              (- expr expr)     subtract
  2022. X              (* expr expr)     multiply
  2023. X              (/ expr expr)     divide
  2024. X              (% expr expr)     remainder
  2025. X
  2026. X              (& expr expr)     bit-wise and
  2027. X              (| expr expr)     bit-wise or
  2028. X              (~ expr)          bit-wise complement
  2029. X
  2030. X            These arithmetic functions operate on integers.  As it turns
  2031. X            out, every data type in the system is represented by an
  2032. X            integer, so these functions will work with any type of
  2033. X            arguments.  They are probably only useful with integers,
  2034. X            however.
  2035. X
  2036. X              (RANDOMIZE)       reset the random number generator
  2037. X              (RAND expr)       generate a random number
  2038. X
  2039. X            These functions enable the generation of pseudo-random
  2040. X            numbers.  The (RAND n) function takes a single argument and
  2041. X            generates a random number between zero and n-1.  (RANDOMIZE)
  2042. X            resets the seed used by the random number function so that
  2043. X            each invocation of a program results in a new sequence of
  2044. X            random numbers.
  2045. X
  2046. X              (AND expr*)       logical and (short circuits)
  2047. X              (OR expr*)        logical or (short circuits)
  2048. X              (NOT expr)        logical not
  2049. X
  2050. X            These functions operate on logical values.  In this system,
  2051. X            any value that is not equal to NIL (or zero) is considered
  2052. X            true.  NIL and zero are considered false.  AND and OR
  2053. X            evaluate their arguments from left to right and stop as soon
  2054. X            as the value of the entire expression can be determined.  In
  2055. X            other words, AND stops when it encounters a false value, OR
  2056. X            stops when it encounters a true value.
  2057. X
  2058. X              (< expr expr)     less than
  2059. X              (= expr expr)     equal to
  2060. X              (> expr expr)     greater than
  2061. X
  2062. X            These functions compare integers.  They cannot be used to
  2063. X            compare strings.
  2064. X
  2065. X
  2066. X
  2067. X
  2068. X
  2069. X
  2070. X
  2071. X
  2072. X
  2073. X
  2074. X
  2075. X
  2076. X
  2077. X
  2078. X
  2079. X
  2080. X
  2081. X        ADVSYS            An Adventure Writing System            Page 15
  2082. X
  2083. X
  2084. X              (GETP obj property-name)          get the value of a property
  2085. X              (SETP obj property-name value)    set the value of a property
  2086. X
  2087. X            These functions manipulate object properties.  They are used
  2088. X            to find the value of a property or to set the value of a
  2089. X            property.  They will also find and set the values of
  2090. X            inherited properties.  If GETP is used to find the value of
  2091. X            a property that doesn't exist for the specified object, NIL
  2092. X            is returned.  If SETP is used to set the value of a property
  2093. X            that doesn't exist, the operation is ignored.
  2094. X
  2095. X              (CLASS obj)
  2096. X
  2097. X            This function returns the class of an object.  If the object
  2098. X            was defined with an (OBJECT ...) statement, NIL will be
  2099. X            returned.  If the object was defined with the (class-name
  2100. X            ...) statement, the class object will be returned.
  2101. X
  2102. X              (MATCH obj noun-phrase-number)
  2103. X
  2104. X            This function matches an object with a noun phrase.  An
  2105. X            object matches a noun phrase if it includes all of the
  2106. X            adjectives specified in the noun phrase and also includes
  2107. X            the noun mentioned.  Both nouns and adjectives can be
  2108. X            inherited.
  2109. X
  2110. X              (YES-OR-NO)       get a yes or no answer from the player
  2111. X
  2112. X            This function waits for the player to type a line.  If the
  2113. X            line begins with a 'Y' or a 'y', the function returns T.  If
  2114. X            the line begins with anything else, the function returns
  2115. X            NIL.
  2116. X
  2117. X              (PRINT expr)                      print a string
  2118. X              (PRINT-NUMBER expr)               print a number
  2119. X              (PRINT-NOUN noun-phrase-number)   print a noun phrase
  2120. X              (TERPRI)                          terminate the print line
  2121. X
  2122. X            These functions perform various sorts of output.  PRINT
  2123. X            prints strings, PRINT-NUMBER prints numbers and PRINT-NOUN
  2124. X            prints a noun phrase.
  2125. X
  2126. X              (FINISH)          exit and continue with the AFTER handler
  2127. X              (CHAIN)           exit and continue with the next handler
  2128. X              (ABORT)           exit and continue with the UPDATE handler
  2129. X              (RESTART)         exit and restart the current game
  2130. X              (EXIT)            exit to the operating system
  2131. X
  2132. X            These functions cause the immediate termination of the
  2133. X            current handler.  FINISH causes execution to proceed with
  2134. X            the AFTER handler, CHAIN causes execution to proceed with
  2135. X            the next handler in the normal sequence, ABORT causes
  2136. X            execution to proceed with the UPDATE handler (effectively
  2137. X            aborting the current turn), RESTART restores the game to its
  2138. X
  2139. X
  2140. X
  2141. X
  2142. X
  2143. X
  2144. X
  2145. X
  2146. X
  2147. X        ADVSYS            An Adventure Writing System            Page 16
  2148. X
  2149. X
  2150. X            original state and starts over with the INIT handler and
  2151. X            EXIT causes an immediate exit back to the operating system.
  2152. X
  2153. X              (SAVE)            save the current game position
  2154. X              (RESTORE)         restore a saved game position
  2155. X
  2156. X            These functions allow the player to save and restore
  2157. X            positions in the game.  They prompt the player for a file
  2158. X            name and either read a saved game position from the file or
  2159. X            write the current game position to the file.
  2160. X
  2161. X              (function-name expr*)
  2162. X
  2163. X            This expression invokes a user defined function.  There
  2164. X            should be one expression for each of the formal arguments of
  2165. X            the user function.  The value of the expression is the value
  2166. X            of the last expression in the body of the user function or
  2167. X            the value passed to a RETURN statement within the function.
  2168. X
  2169. X              (SEND object selector [expr]*)
  2170. X
  2171. X            This expression sends a message to an object.  The "object"
  2172. X            expression should evaluate to an object.  The selector
  2173. X            should match a method selector for that object or one of its
  2174. X            super-classes.  The matching method is invoked with the
  2175. X            specified expressions as arguments.  Also, the implied
  2176. X            argument SELF will refer to the object receiving the
  2177. X            message.
  2178. X
  2179. X              (SEND-SUPER selector [expr]*)
  2180. X
  2181. X            This expression sends a message to the super-class of the
  2182. X            current object.  It can only be used within a method and it
  2183. X            will cause the message to be passed up the class heirarchy
  2184. X            to the super-class of the object refered to by SELF.
  2185. X
  2186. X              (SETQ variable value)
  2187. X
  2188. X            This expression sets the value of a user variable.
  2189. X
  2190. X              (COND [(test expr*)]*)            execute conditionally
  2191. X              (IF test then-expr [else-expr])   traditional if-then-else
  2192. X              (WHILE test expr*)                conditional iteration
  2193. X              (PROGN expr*)                     block construct
  2194. X              (RETURN [expr])                   return from a function
  2195. X
  2196. X            These statements are control constructs.
  2197. X
  2198. X
  2199. X
  2200. X
  2201. X
  2202. X
  2203. X
  2204. X
  2205. X
  2206. X
  2207. X
  2208. X
  2209. X
  2210. X
  2211. X
  2212. X
  2213. X        ADVSYS            An Adventure Writing System            Page 17
  2214. X
  2215. X
  2216. X        Primary expressions:
  2217. X
  2218. X            integer             (digits preceeded by an optional sign)
  2219. X            string              (characters enclosed in double quotes)
  2220. X            action-name         (an action name)
  2221. X            object-name         (an object or class name)
  2222. X            property-name       (a property name)
  2223. X            constant-name       (a defined constant or function)
  2224. X            variable-name       (a variable name)
  2225. X
  2226. X            Since an adventure description contains a large quantity of
  2227. X            running text, the format for specifying string constants is
  2228. X            somewhat extended from normal programming languages.  In
  2229. X            this system, a string is enclosed in double quotes.  If the
  2230. X            end of line occurs before the closing quote within a string,
  2231. X            it is treated as if it were a space.  Any number of
  2232. X            consecutive spaces is collapsed into a single space.  Also,
  2233. X            the character pair "\\n" is used to represent the "end of
  2234. X            line" character, the pair "\\t" is used to represent the tab
  2235. X            character and the pair "\\\\" is used to represent the
  2236. X            backslash character.
  2237. X
  2238. X          Examples:
  2239. X
  2240. X                "This is a string.\\n"
  2241. X                "This
  2242. X                 is
  2243. X                 a
  2244. X                 string.\\n"
  2245. X
  2246. X            Both of the examples above represent the same string.
  2247. X
  2248. X
  2249. X
  2250. X
  2251. X
  2252. X
  2253. X
  2254. X
  2255. X
  2256. X
  2257. X
  2258. X
  2259. X
  2260. X
  2261. X
  2262. X
  2263. X
  2264. X
  2265. X
  2266. X
  2267. X
  2268. X
  2269. X
  2270. X
  2271. X
  2272. X
  2273. X
  2274. X
  2275. X
  2276. X
  2277. X
  2278. X
  2279. X        ADVSYS            An Adventure Writing System            Page 18
  2280. X
  2281. X
  2282. X        Definitions of symbols used above:
  2283. X
  2284. X            expr                an expression
  2285. X            value               an expression
  2286. X            test                an expression (NIL means false, anything
  2287. Xelse is true)
  2288. X            then-expr           an expression
  2289. X            else-expr           an expression
  2290. X            obj                 an expression that evaluates to an object
  2291. X            property-name       an expression that evaluates to a property
  2292. Xname
  2293. X            noun-phrase-number  an expression that evaluates to a noun
  2294. Xphrase number
  2295. X            variable            a variable name
  2296. X            T                   true
  2297. X            NIL                 false
  2298. X
  2299. X
  2300. X        Built-in variables set by the parser:
  2301. X
  2302. X            $ACTOR              (actor noun phrase number)
  2303. X            $ACTION             (action)
  2304. X            $DOBJECT            (first direct object noun phrase number)
  2305. X            $NDOBJECTS          (number of direct object noun phrases)
  2306. X            $IOBJECT            (indirect object noun phrase number)
  2307. X
  2308. X
  2309. X        Other built-in variables:
  2310. X
  2311. X            $OCOUNT             (total number of objects in the system)
  2312. X
  2313. X
  2314. X        CURRENT COMPILER LIMITS
  2315. X
  2316. X            500         words
  2317. X            500         objects
  2318. X            20          properties per object
  2319. X            200         actions or functions
  2320. X            16384       bytes of code
  2321. X            16384       bytes of data
  2322. X            262144      bytes of text
  2323. X
  2324. X
  2325. X
  2326. X
  2327. X
  2328. X
  2329. X
  2330. X
  2331. X
  2332. X
  2333. X
  2334. X
  2335. X
  2336. X
  2337. X
  2338. X
  2339. X
  2340. X
  2341. X
  2342. X
  2343. X
  2344. X
  2345. END_OF_advsys.doc
  2346. if test 29358 -ne `wc -c <advsys.doc`; then
  2347.     echo shar: \"advsys.doc\" unpacked with wrong size!
  2348. fi
  2349. # end of overwriting check
  2350. fi
  2351. echo shar: End of archive 1 \(of 3\).
  2352. cp /dev/null ark1isdone
  2353. MISSING=""
  2354. for I in 1 2 3 ; do
  2355.     if test ! -f ark${I}isdone ; then
  2356.     MISSING="${MISSING} ${I}"
  2357.     fi
  2358. done
  2359. if test "${MISSING}" = "" ; then
  2360.     echo You have unpacked all 3 archives.
  2361.     rm -f ark[1-9]isdone
  2362. else
  2363.     echo You still need to unpack the following archives:
  2364.     echo "        " ${MISSING}
  2365. fi
  2366. ##  End of shell archive.
  2367. exit 0
  2368.  
  2369.  
  2370.  
  2371.